﻿@using VaccineClient.Services
@inherits LayoutComponentBase
@inject NavigationManager navigationManager
@inject IAuthService AuthService


<div class="page">
    <AuthorizeView>
        <Authorized>
            @*Show the menu and the rest of the body*@
            <div class="sidebar">
                <NavMenu />
            </div>

            <div class="main" style="width:100%;">
                <div class="top-row px-4">
                    <button type="button" class="btn btn-link ml-md-auto" @onclick="@LogoutClick">退出登录</button>
                </div>
                <div class="content px-4">
                    @Body
                </div>
            </div>
        </Authorized>
        <NotAuthorized>
            @*Just render the body so that RedirectToLogin works*@
            @Body
        </NotAuthorized>
    </AuthorizeView>
</div>
@code {

    async  Task LogoutClick()
    {
        await AuthService.Logout();
        navigationManager.NavigateTo("/",true);
    }
}